import 'dart:convert' show json;

import 'file_loxen.dart';

T asT<T>(dynamic value) {
  if (value is T) {
    return value;
  }

  return null;
}

class MasterIndexBean {
  MasterIndexBean({
    this.code,
    this.data,
  });

  factory MasterIndexBean.fromJson(Map<String, dynamic> jsonRes) => jsonRes == null
      ? null
      : MasterIndexBean(
          code: asT<int>(jsonRes['code']),
          data: Data.fromJson(asT<Map<String, dynamic>>(jsonRes['data'])),
        );

  int code;
  Data data;

  Map<String, dynamic> toJson() => <String, dynamic>{
        'code': code,
        'data': data,
      };

  @override
  String toString() {
    return json.encode(this);
  }
}

class Data {
  Data({
    this.results,
  });

  factory Data.fromJson(Map<String, dynamic> jsonRes) => jsonRes == null
      ? null
      : Data(
          results:
              FileShow.fromJson(asT<Map<String, dynamic>>(jsonRes['results'])),
        );

  FileShow results;

  Map<String, dynamic> toJson() => <String, dynamic>{
        'results': results,
      };

  @override
  String toString() {
    return json.encode(this);
  }
}

class FileShow {
  FileShow({
    this.article,
    this.product,
    this.picture,
  });

  factory FileShow.fromJson(Map<String, dynamic> jsonRes) {
    if (jsonRes == null) {
      return null;
    }

    final List<FileLoxen> article =
        jsonRes['article'] is List ? <FileLoxen>[] : null;
    if (article != null) {
      for (final dynamic item in jsonRes['article']) {
        if (item != null) {
          article
              .add(FileLoxen.fromJson(asT<Map<String, dynamic>>(item)));
        }
      }
    }

    final List<FileLoxen> product =
        jsonRes['product'] is List ? <FileLoxen>[] : null;
    if (product != null) {
      for (final dynamic item in jsonRes['product']) {
        if (item != null) {
          product.add(FileLoxen.fromJson(asT<Map<String, dynamic>>(item)));
        }
      }
    }

    final List<FileLoxen> picture =
        jsonRes['picture'] is List ? <FileLoxen>[] : null;
    if (picture != null) {
      for (final dynamic item in jsonRes['picture']) {
        if (item != null) {
          picture.add(FileLoxen.fromJson(asT<Map<String, dynamic>>(item)));
        }
      }
    }
    return FileShow(
      article: article,
      product: product,
      picture: picture,
    );
  }

  List<FileLoxen> article;
  List<FileLoxen> product;
  List<FileLoxen> picture;

  Map<String, dynamic> toJson() => <String, dynamic>{
        'article': article,
        'product': product,
        'picture': picture,
      };

  @override
  String toString() {
    return json.encode(this);
  }
}



